<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="CYW">
    <title></title>
    <style>
        body{
            margin: 0;
        }
        *{
            box-sizing: border-box;
        }
        .box{
            width: 300px;
            margin: 0 auto;
            /* border:1px solid red; */
            position: relative;
        }
        .box>div{
            display: flex;
        }
        .box>div span{
            width: 120px;
            line-height: 30px;
            text-align: center;
            background-color: lightcoral;
        }
        div span.select{
            background-color: skyblue;
        }
         .list{
            list-style: none;
            margin:0;
            padding: 0;
            position: absolute;
            top: 30px;
            left: 120px;
            width: 120px;
            text-align: center;
            display: none;
        } 
        .list li{
            margin: 10px;
        }
        .list li:hover{
            background-color: lightgray;
        }
    
    </style>
</head>
<body>
    <div class="box">
        <div>
            <span>我的项目:</span>
            <span class="select">未选择</span>
        </div>
        <ul class="list">
            <li>html5</li>
            <li>css</li>
            <li>javaScript</li>
            <li>jQuery</li>
            <li>node.js</li>
        </ul>
    </div>
  <script src="jquery.js"></script>
</body>
</html>
<script>
    var result;



    $('.select').click(function(ev){
    // 阻止冒泡
    // 点击span.select时 不触发document的点击事件 
    console.log(ev.target);
    ev.stopPropagation();
    // 
        // $('.list').css('display','block')
      $('.list').toggle();
    //   开关 toggle
      $('.list li').click(function(){
          if($('.select').text()!=result){
             $('.select').html($(this).text());
          }
        
      });
    //    点击document .list隐藏
      $(document).click(function(){
       $('.list').hide();
      });

    });

</script>